<%@ page import="java.sql.*" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<style type="text/css">

</style>
<body>
<p>跳转中....</p>
<%
    request.setCharacterEncoding("UTF-8");
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    Connection connection=null;
    Statement statement=null;
    try{
        Class.forName("com.mysql.jdbc.Driver");
    }
    catch (ClassNotFoundException e){
        e.printStackTrace();
    }
    try {
        connection= DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC&characterEncoding=gbk",
                "root",
                "w19971201t");
        statement=connection.createStatement();
        //statement.execute("CREATE TABLE t_user(username VARCHAR(50) PRIMARY KEY ,password VARCHAR(50) )");
        statement.executeUpdate("INSERT INTO t_user(username,password) VALUES ('"+username+"','"+password+"')");
    }
    catch (SQLException e){
        e.printStackTrace();
    }
    finally {
        try {

            connection.close();
            statement.close();

        }
        catch (SQLException e){
            e.printStackTrace();
        }
    }

%>
<script type="text/javascript">
    onload=function () {
        setTimeout(go(),100)
    }
    function go() {
        location.href="http://localhost:8080/userList.jsp"
    }
</script>
</body>
</html>